from functools import cache
from typing import *

from math import inf


class Solution:
    def findMinimumTime(self, strength: List[int], k: int) -> int:
        n = len(strength)

        @cache
        def f(locks, x):
            if locks == 0:
                return 0
            ans = inf
            for i in range(n):
                if locks >> i & 1 == 1:
                    ans = min(
                        ans, (strength[i] + x - 1) // x + f(locks ^ (1 << i), x + k)
                    )
            return ans

        return f((1 << n) - 1, 1)
